package com.yangyang.androidconnect.controller;

import com.yangyang.androidconnect.common.ApiResult;
import com.yangyang.androidconnect.data.UserManager;
import com.yangyang.androidconnect.vo.request.LoginRequestVO;
import com.yangyang.androidconnect.vo.response.LoginUserResponse;
import com.yanzhenjie.andserver.annotation.PostMapping;
import com.yanzhenjie.andserver.annotation.RequestBody;
import com.yanzhenjie.andserver.annotation.RequestMapping;
import com.yanzhenjie.andserver.annotation.RestController;

@RestController
@RequestMapping(path = "/user")
public class UserController {

    @PostMapping("/login")
    public ApiResult login(@RequestBody LoginRequestVO body) throws Exception {
        System.out.println(body);
        LoginUserResponse loginUser = UserManager.getLoginUser(body.getUsername(), body.getPassword());
        return ApiResult.ok(loginUser);
    }

//    @GetMapping(path = "/{userId}")
//    public User info(@PathVariable("userId") String userId,
//                     @QueryParam("fields") String fields) {
//
//        //User user = findUserById(userId, fields);
//        User user = new User();
//        return user;
//    }

//    @PutMapping(path = "/{userId}")
//    public void modify(@PathVariable("userId") String userId,
//                       @RequestParam("age") int age) {
//    }

}